/**
 * 
 */
package com.jtmproject.database;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

/**
 * Represents data from a Customer
 * @author Pello Xabier Altadill Izura
 *
 */
@Entity
@Table(name="role")
public class Role {
	
	@Id
	@GeneratedValue
	@Column(name="id")
	private int id;
	
	@Column(name="name")
	private String name;
	
	@Column(name="description")
	private String description;
	
	@OneToMany(mappedBy="role")
	@Fetch(FetchMode.JOIN)
	private Set<User> users;
	
	/**
	 * default constructor
	 */
	public Role () {
		
	}
	
	/**
	 * constructor with parameters
	 * @param id
	 * @param name
	 * @param description
	 */
	public Role(int id, String name, String description) {
		this.id = id;
		this.name = name;
		this.description = description;
	}



	/**
	 * returns the id
	 * @return
	 */
	public int getId() {
		return id;
	}

	/**
	 * sets the id
	 * @param id
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * returns the name
	 * @return
	 */
	public String getName() {
		return name;
	}

	/**
	 * sets the name
	 * @param name
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * returns the description
	 * @return
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * sets the description
	 * @param description
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * returns the users
	 * @return
	 */
	public Set<User> getUsers() {
		return users;
	}
	
	/**
	 * sets the 
	 * @param users
	 */
	public void setUsers(Set<User> users) {
		this.users = users;
	}
	
	@Override
	public String toString(){
		return name + " - " + id;
	}
	
}
